const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const sourceMapList = require('./SourceMap');

/** @type {import('webpack').Configuration} */
module.exports = sourceMapList.map(item => {
  return {
    devtool: item,
    mode: 'none', // 确保 webapck 内部不做额外的处理
    entry: './src/main.js',
    output: {
      filename: `js/${item}.js`,
      path: path.resolve(__dirname, 'dist'),
      clean: true,
    },
    module: {
      rules: [
        {
          test: /\.js$/i,
          include: path.resolve(__dirname, 'src'),
          loader: 'babel-loader',
          options: {
            presets: ['@babel/preset-env'],
          },
        },
      ],
    },
    plugins: [
      new HtmlWebpackPlugin({
        template: path.resolve(__dirname, 'public/index.html'),
        filename: `${item}.html`,
      }),
    ],
  };
});
